package cn.u313.comm.utils;

import cn.u313.comm.conststring.TxtzhuFU;


import java.util.Arrays;

import static cn.u313.comm.utils.Util.iconXQ;

public class ResultBlessing {
    public double 红包=0.01;
    public double 倍率=0;
    public int 中奖初始数量=0;
    public int 总数=0;
    public int n=-1;
    private int 套数 = 1;
    private int 卡片补贴 = 0;
    private int 套数补贴 = 0;
    public int number=0;
    public int r=0;
    int numbers[]={555,666,888,999,1688,2023};
    double px[][]={
            {1.24,1.26,1.27,1.28,1.36},
            {1.16,1.17,1.18,1.19,1.19},
            {1.25,1.26,1.27,1.28,1.28},
            {1.15,1.16,1.17,1.18,1.18},
            {1.01,1.04,1.08,1.12,1.16},
            {1,1,1,1,1}
    };

    double[] 红包种子={
            0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
            0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,
            0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,
            0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,
            0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,
            0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,
            0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,
            0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,
            0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,
            0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,
            0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,
            0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,
            0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,
            0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,
            0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,0.08,
            0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,
            0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,
            0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,
            0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,
            0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,
            0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,
            0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,
            0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,
            0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,0.09,
            0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,
            0.16,0.16,0.16,0.16,
            0.2,0.2,0.2,0.2,
            0.23,0.23,0.23,0.23,
            0.66,0.66,0.66,
            0.88,0.88,
            0.99,
            1.68
    };

    /**
     * 开始领奖
     * @param number
     * @return
     */
    public ResultBlessing ditry(int number,int nn){
        n=getNu(number);
        中奖初始数量=numbers[n];
        套数 = Math.min(nn, 7);
        倍率=px[n][(int)(px[n].length*(Math.random()))];
        总数=(int)(中奖初始数量*倍率)+66;
        if(套数>1)
            套数补贴 = 120*(套数-1);//套数奖励
        if(number>10)
            if(number>=70)
                卡片补贴 =  (number-40)*10;//卡片补贴
            else if(number>=40)
                卡片补贴 =  (number-40)*1;//卡片补贴
            else if(number>=20)
                卡片补贴 =  (number-20)*10;//卡片补贴
            else
                卡片补贴 =  (number-10)*20;//卡片补贴
        总数 = 总数 + 卡片补贴 +套数补贴;
        this.number=number;
        hb();
        return this;
    }
    private void hb(){
        if(n<2){
            红包=红包种子[(int)(Math.random()*红包种子.length-10)+10];
        }else
            红包=红包种子[(int)(Math.random()*红包种子.length+30)-30];
    }
    private int getNu(int number){
//        double d=number/30;
        int r=(int)(Math.random()*100);
        this.r=r;
        if(r>97){
            return 5;
        }
        if(number<10){
            return 0;
        }else if(number<20){
            return 1;
        }else if(number<30){
            return 2;
        }else if(number<40){
            return 3;
        }else{
            return 4;
        }
    }

    //    @Override
    public String toString() {

        return  iconXQ+"成功兑换兔卡奖励！\n" +
                iconXQ+"初始悦币："+中奖初始数量+"\n" +
                iconXQ+"悦币倍率："+倍率+"\n" +
                iconXQ+"获得红包："+红包+" \uD83E\uDDE7\n" +
                iconXQ+"兔卡数量："+number+" 张\n" +
                iconXQ+"集齐数量："+套数+" 套\n" +
                iconXQ+"集齐补贴："+套数补贴+" 悦币\n" +
                iconXQ+"好运补贴："+(卡片补贴 + 2)+" 悦币\n" +
                iconXQ+"新年补贴：66 悦币\n" +
                iconXQ+"瓜分总计："+总数+" 悦币";
    }
    public String test() {
        return "ResultBlessing{" +
                "红包=" + 红包 +
                ", 倍率=" + 倍率 +
                ", 中奖初始数量=" + 中奖初始数量 +
                ", 总得悦币数=" + 总数 +
                ", n=" + n +
                ", 套数=" + 套数 +
                ", 抽卡次数=" + number +
                ", 成本=" + number*20 +
                ", 收益=" + (总数 - number*20) +
                ", 套数补贴=" + 套数补贴 +
                ", 卡片补贴=" + 卡片补贴 +
                ", r=" + r +
                '}';
    }

    public static void main(String[] args) {
        int i = 300;
        for (int i1 = i; i1 > 250; i1--) {
            ResultBlessing resultBlessing = new ResultBlessing();
            resultBlessing.ditry(i1,(i1/5*3)/5);
            System.out.println(resultBlessing.test());

        }
    }
}
